
/**
 * 获取当前页面URL，带有备用逻辑
 * @returns {string} 当前页面的完整URL
 */
function getCurrentUrlWithFallback() {
    // 方法1: 首选window.location.href
    try {
        if (window && window.location && window.location.href) {
            return window.location.href;
        }
    } catch (e) {
        console.warn('Failed to get URL via window.location.href, trying fallback methods...');
    }

    // 方法2: 尝试document.location.href
    try {
        if (document && document.location && document.location.href) {
            return document.location.href;
        }
    } catch (e) {
        console.warn('Failed to get URL via document.location.href, trying next fallback...');
    }

    // 方法3: 尝试document.URL
    try {
        if (document && document.URL) {
            return document.URL;
        }
    } catch (e) {
        console.warn('Failed to get URL via document.URL, trying final fallback...');
    }

    // 方法4: 最后尝试document.location.toString()
    try {
        if (document && document.location) {
            return document.location.toString();
        }
    } catch (e) {
        console.error('All URL retrieval methods failed!');
        throw new Error('Could not retrieve current URL using any known method');
    }

    // 如果所有方法都失败(理论上不应该到达这里)
    return '';
}

kittlenMinShow(getCurrentUrlWithFallback());
